package sinfoci.alquimiabtl.notificaciones.utilities;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Utilities {

	public static String getSizePermitted(String cadena, int size) {

		if (cadena == null) {
			return " ";
		}

		if (cadena.length() > size) {
			cadena.substring(0, size);
			cadena += "...";
		}

		return cadena;

	}

	public static Boolean validarCorreo(String email) {
		
		if(email == null){
			return Boolean.FALSE;
		}
		
		email = email.trim();
		String PATTERN_EMAIL = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
				+ "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
		// Compiles the given regular expression into a pattern.
		Pattern pattern = Pattern.compile(PATTERN_EMAIL);

		// Match the given input against this pattern
		Matcher matcher = pattern.matcher(email);
		return matcher.matches();

	}

}
